home *** CD-ROM | disk | FTP | other *** search
- ;use up memory by allocating and staying resident
- ;for memory size testing of various programs
- ;call as EATMEM kBytesToEat
- ;
- ;written 8/7/85 K. Kokkonen, TurboPower Software, 408-378-3672
-
- eat proc far
-
- ;parse command line to get amount of memory to eat
- mov si,81H ;point to command line string
- mov di,offset(amount$) ;and to string storage area
- xor cx,cx ;count chars in cx
- cld
- getst lodsb ;get first non-blank
- cmpb al,' '
- je getst
- cmpb al,13 ;check for end of input
- jne more
- mov dx,offset(noinp$) ;no parameter specified ==>error
- jmps error
-
- more inc cx
- stosb ;store the non-blank character
- lodsb ;get next char into al
- cmpb al,' ' ;terminate with <space> or <cr>
- je done
- cmpb al,13
- je done
- jmps more
-
- ;convert amount$ to an integer in amount
- ;cx holds count of chars
- ;first put a terminator on amount
- done mov al,36
- stosb ;put string terminator on amount$
- mov si,offset(amount$)
- mov di,10
- inc cx
- nextc dec cx
- jcxz eatit ;exit if all digits used
-
- mov ax,amount ;partial result into ax
- mul ax,di ;multiply by 10 (should all fit in ax)
- mov amount,ax ;store ax
-
- lodsb ;next char into al
- cmp al,30H ;make sure it's a digit
- jb baddig
- cmp al,39H
- ja baddig
- and al,0FH ;convert to digit
- xor ah,ah
- add amount,ax ;add to amount
- jmps nextc
-
- ;calculate the paragraphs to eat up
- eatit mov dx,amount
- cmp dx,512
- ja baddig ;don't eat more than 512k
- push dx
-
- ;show a success message
- mov dx,offset(succ1$)
- mov ah,9
- int 21H
- mov dx,offset(succ2$)
- mov ah,9
- int 21H
-
- ;eat up the memory (must reboot to free)
- pop dx
- mov cl,6
- shl dx,cl ;convert kB to paras
- mov ax,3100H ;return code 0
- int 21H ;exit and remain resident
-
- baddig mov dx,offset(baddig$)
-
- error mov ah,9
- int 21H
- int 20H
-
- succ1$ db 13,10,'Eating up '
- amount$ db 0,0,0,0 ;string holding amount of kB
- succ2$ db ' kBytes of RAM space',13,10,36
- amount db 0,0 ;integer holding amount of kb, then paras
- noinp$ db 13,10,'No parameter specified. Usage: EATMEM kBtoEat',13,10,36
- baddig$ db 13,10,'Bad number of kB specified',13,10,36
-
- endp